/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2024-05-09 11:02:48
 * @LastEditors: icymoon911 icymoon911@163.com
 * @LastEditTime: 2024-10-13 14:25:09
 * @FilePath: \ken147258.topayClient\src\api\other\order.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */


import request from "@/utils/request";
import axios, { AxiosPromise } from "axios";

const URL = {
  add: '/tg_msg/add',
  dels: '/tg_msg/dels',
  update: '/tg_msg/update',
  autoSend: '/tg_msg/autoSend',
  list: '/tg_msg/getList',
  getGroups: '/tg_msg/getGroups',
  sendMsg: '/tg_msg/sendMsg',
  getFileUrlById: '/tg_msg/getFileUrlById',
};

export function add(data: object): AxiosPromise<any> {
  return request({
    url: URL.add,
    method: "post",
    data: data,
  });
}

export function dels(data: object): AxiosPromise<any> {
  return request({
    url: URL.dels,
    method: "post",
    data: data,
  });
}

export function update(data: object): AxiosPromise<any> {
  return request({
    url: URL.update,
    method: "post",
    data: data,
  });
}
export function autoSend(data: object): AxiosPromise<any> {
  return request({
    url: URL.autoSend,
    method: "post",
    data: data,
  });
}

export function sendMsg(data: object): AxiosPromise<any> {
  return request({
    url: URL.sendMsg,
    method: "post",
    data: data,
  });
}

/**
 * 获取群组
 * @param data
 * @returns [{  "id": "-4180199537",
                "group_name": "测试群-机器人",
                "createtime": 1722838954826}]
 */
export function getGroups(data: object): AxiosPromise<any> {
  // return new Promise((resolve, reject) => {
  //   axios.get(URL.getGroups)
  //     .then((res) => {
  //       resolve(res);
  //     })
  //     .catch((err) => {
  //       reject(err);
  //     });
  // });

  return request({
    url: URL.getGroups,
    method: "get",
    params: data,
  });
}

export function list(data: object): AxiosPromise<any> {
  return request({
    url: URL.list,
    method: "get",
    params: data,
  });
}

export function getFileUrlById(data: object): AxiosPromise<any> {
  return request({
    url: URL.getFileUrlById,
    method: "get",
    params: data,
  });
}
